package list_Node;

import java.util.PriorityQueue;

//148. 排序链表
public class Num148_sortList {
    public ListNode sortList(ListNode head) {
        PriorityQueue<ListNode> queue = new PriorityQueue<>((x,y)->x.val-y.val);
        while (head!=null){
            queue.offer(head);
            head = head.next;
        }
        ListNode root = new ListNode();
        ListNode item = root;
        while (!queue.isEmpty()) {
            item.next = queue.poll();
            item = item.next;
        }
        item.next = null;
        return root.next;
    }
}
